package com.ce.framework.datamaintain.logic;

import java.sql.ResultSet;
import java.sql.SQLException;

public interface ISQLMapper<E>
{
	
	public static ISQLMapper<?> mapper = new ISQLMapper<Object>(){

																	public Object fromSQLQuery(ResultSet rs, int row) {
																		Object[] ary = null;
																		try {
																			int cnt = rs.getMetaData().getColumnCount();
																			ary = new Object[cnt];
																			for(int i=0;i<cnt;i++){
																				ary[i] = rs.getObject(i+1);
																			}
																		} catch (SQLException e) {
																			e.printStackTrace();
																		}
																		if(ary.length==1)
																			return ary[0];
																		return ary;
																	}

																};

	public static ISQLMapper<String> strMapper = new ISQLMapper<String>()
																		{

																			public String fromSQLQuery(ResultSet rs, int row) {
																				try {
																					return rs.getString(1);
																				} catch (SQLException e) {
																					e.printStackTrace();
																				}
																				return null;
																			}

																		};
	
	E fromSQLQuery(ResultSet rs,int num);

}
